package com.witmed.service.impl;

import java.util.List;
import java.util.Map;

import com.witmed.dao.ArticleDao;
import com.witmed.dao.impl.ArticleDaoImpl;
import com.witmed.entity.Article;
import com.witmed.service.ArticleService;
import com.witmed.util.PageInfo;

public class ArticleServiceImpl implements ArticleService{

	ArticleDao articleDao = new ArticleDaoImpl();
	
	@Override
	public boolean insert(Article article) {
		return articleDao.insert(article) == 1 ? true : false;
	}

	@Override
	public boolean deleteById(int articleId) {
		return articleDao.deleteById(articleId) == 1 ? true : false;
	}

	@Override
	public List<Article> getFindByArticleTitle(String articleTitle) {
		return articleDao.findByArticleTitle(articleTitle);
	}

	@Override
	public PageInfo<Article> getFindByPage(int pageNum, int pageSize) {
		return articleDao.findByPage(pageNum, pageSize) ;
	}

	@Override
	public PageInfo<Article> getFindByPage(int pageNum, int pageSize, Article article) {
		if(pageNum <= 0) {
			pageNum = 1;
		}
		
		if(pageSize <= 0) {
			pageSize = 2;
		}
		
		return articleDao.findByPage(pageNum, pageSize, article);
	}

	@Override
	public boolean update(Article article) {
		return articleDao.update(article) == 1 ? true : false;
	}

	@Override
	public List<Article> getFindByAll() {
		return articleDao.findByAll();
	}

	@Override
	public List<Article> getArticleListOrderByCondition(Map<String, Object> map) {
		return articleDao.findByOrder(map);
	}

}
